//
//  WUExpertFindViewCell.m
//  Home
//
//  Created by 吴军虎吴军虎 on 16/5/4.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "WUExpertFindViewCell.h"

@interface WUExpertFindViewCell() 

@property (nonatomic,retain)UILabel *priceL;
@property (nonatomic,retain)UILabel *addressL;
@property (nonatomic,retain)UILabel *ageL;
@property (nonatomic,retain)UILabel *styleL;

@property (nonatomic,retain)UIImageView *sexImageView;
@property (nonatomic,retain)UILabel *nameL;
@property (nonatomic,retain)UIImageView *imageView1;
@property (nonatomic,retain)UIImageView *imageView2;
@property (nonatomic,retain)UIImageView *imageView3;
@property (nonatomic,retain)UILabel *text1;
@property (nonatomic,retain)UILabel *text2;
@property (nonatomic,retain)UILabel *text3;
@property (nonatomic,retain)UILabel *text4;

@property (nonatomic,retain)UIImageView *flowerImageView;
@property (nonatomic,retain)UIImageView *eggImageView;
@property (nonatomic,retain)UILabel *flowweL;
@property (nonatomic,retain)UILabel *eggL;


@end

@implementation WUExpertFindViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatView];
    }
    return self;
}

- (void)creatView{
    
    
    _myImageView = [UIImageView new];
    [self.contentView addSubview:_myImageView];
    
    _myImageView.image = [UIImage imageNamed:@"backImage"];
    [_myImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).offset(30/2 * AUTO_HEIGHT);
        make.width.mas_equalTo(55 * AUTO_WIDTH);
        make.height.mas_equalTo(55 * AUTO_HEIGHT);
        make.centerXWithinMargins.mas_equalTo(self);
        
    }];
    _myImageView.layer.masksToBounds = YES;
    _myImageView.layer.cornerRadius = 55/2 * AUTO_WIDTH;
    _myImageView.contentMode = UIViewContentModeScaleAspectFill;
    
    
    
    _sexImageView = [UIImageView new];
    //_sexImageView.backgroundColor = [UIColor redColor];
    _sexImageView.image = [UIImage imageNamed:@"xingbeinan"];
    [self.contentView addSubview:_sexImageView];
    [_sexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_myImageView).offset(5 * AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(15 *AUTO_WIDTH, 15 * AUTO_HEIGHT));
        make.right.mas_equalTo(_myImageView.mas_right).offset(-0 * AUTO_WIDTH);
        
    }];
    
    
    
    
    //nameL
    _nameL = [UILabel new];
    [self.contentView addSubview:_nameL];
    _nameL.text = @"张叶君";
    _nameL.font = [UIFont fontWithName:TFont size:LOGINFONT * AUTO_WIDTH];
    _nameL.textColor = [UIColor colorWithWhite:0.000 alpha:0.580];
    [_nameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_myImageView.mas_bottom).offset(5 * AUTO_HEIGHT);
        // make.left.mas_equalTo(_myImageView.mas_right).offset(15 * AUTO_WIDTH);
        make.centerXWithinMargins.mas_equalTo(self);

        make.height.mas_equalTo(17 * AUTO_HEIGHT);

        
    }];
    
    
    //价格图片
    UIImageView *priceIV = [UIImageView new];
    [self.contentView addSubview:priceIV];
    priceIV.image = [UIImage imageNamed:@"qiang"];
    [priceIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_nameL.mas_bottom).offset(40/3 * AUTO_HEIGHT);
        make.left.mas_equalTo(108/2 * AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(15 * AUTO_WIDTH, 15 * AUTO_HEIGHT));
        
    }];
    
    //价格
    _priceL = [UILabel new];
    [self.contentView addSubview:_priceL];
    _priceL.text = @"30000";
    _priceL.textColor = ZI;
    _priceL.font = [UIFont fontWithName:TFont  size:TEXTCONTENTFONT2 * AUTO_WIDTH];
    [_priceL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(priceIV.mas_right).offset(3 * AUTO_WIDTH);
        make.height.mas_equalTo(priceIV);
        
        
    }];
    
   
    //面积图片
    UIImageView *addressIV = [UIImageView new];
    [self.contentView addSubview:addressIV];
    addressIV.image = [UIImage imageNamed:@"area"];
    [addressIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(_priceL.mas_right).offset( 8 * AUTO_WIDTH);
        make.size.mas_equalTo(priceIV);
        
    }];
    //面积名
    _addressL = [UILabel new];
    [self.contentView addSubview:_addressL];
    _addressL.text = @"1199㎡";
    _addressL.textColor = ZI;
   _addressL.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT2 * AUTO_WIDTH];
    [_addressL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(addressIV.mas_right).offset(3 * AUTO_WIDTH);
        make.height.mas_equalTo(priceIV);
        
    }];
    //定位图片
    UIImageView *adgImageV = [UIImageView new];
    [self.contentView addSubview:adgImageV];
    adgImageV.image = [UIImage imageNamed:@"DIZHI"];
    [adgImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(_addressL.mas_right).offset(8 * AUTO_WIDTH);
        make.size.mas_equalTo(priceIV);
        
    }];
    
    _ageL = [UILabel new];
    _ageL.text = @"杭州";
    [self.contentView addSubview:_ageL];
    _ageL.textColor = ZI;
    _ageL.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT2 * AUTO_WIDTH];
    [_ageL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(adgImageV.mas_right).offset(3 * AUTO_WIDTH);
        make.height.mas_equalTo(priceIV);
        
    }];
    
    //设计
    UIImageView *fengeV = [UIImageView new];
    [self.contentView addSubview:fengeV];
    fengeV.image = [UIImage imageNamed:@"plan"];
    [fengeV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(_ageL.mas_right).offset(8 * AUTO_WIDTH);
        make.size.mas_equalTo(priceIV);
        
    }];
    _styleL = [UILabel new];
    _styleL.text = @"室内设计";
    _styleL.textColor = ZI;
    _styleL.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT2 * AUTO_WIDTH];
    [self.contentView addSubview:_styleL];
    [_styleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(priceIV);
        make.left.mas_equalTo(fengeV.mas_right).offset(3 * AUTO_WIDTH);
        make.height.mas_equalTo(priceIV);
        //  make.right.mas_equalTo(self.mas_right).offset(-40 * AUTO_WIDTH);
        //        make.width.mas_equalTo()
    }];
    
    //
    _imageView1 = [UIImageView new];
    [self.myBackWhiteView addSubview:_imageView1];
    _imageView1.clipsToBounds = YES;
    _imageView1.contentMode = UIViewContentModeScaleAspectFill;
    [_imageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_priceL.mas_bottom).offset(30/3 * AUTO_HEIGHT);
        make.left.mas_equalTo(5 * AUTO_WIDTH);
        make.height.mas_equalTo(230/3 * AUTO_HEIGHT);
        make.width.mas_equalTo((SCREEN_WIDTH-16 * AUTO_WIDTH - 6/2 * 2 * AUTO_WIDTH)/3);
        
    }];
//    _imageView1.contentMode = UIViewContentModeScaleToFill;
    // _imageView1.backgroundColor = [UIColor redColor];
    _imageView1.image = [UIImage imageNamed:@"u=957005295,3708602591&fm=206&gp=0.jpg"];
    
    
    
    _imageView2 = [UIImageView new];
    [self.myBackWhiteView addSubview:_imageView2];
    [_imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_imageView1);
        make.left.mas_equalTo(_imageView1.mas_right).offset(3 * AUTO_WIDTH);
        make.height.mas_equalTo(_imageView1);
        make.width.mas_equalTo(_imageView1);
        
    }];
    _imageView2.clipsToBounds = YES;
    _imageView2.contentMode = UIViewContentModeScaleAspectFill;
    _imageView2.image = [UIImage imageNamed:@"u=957005295,3708602591&fm=206&gp=0.jpg"];
    
    
    
    _imageView3 = [UIImageView new];
    [self.myBackWhiteView addSubview:_imageView3];
    [_imageView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_imageView1);
        make.left.mas_equalTo(_imageView2.mas_right).offset(3 * AUTO_WIDTH);
        make.height.mas_equalTo(_imageView1);
        
        make.right.mas_equalTo(self.myBackWhiteView.mas_right).offset(-5 * AUTO_WIDTH);
        
    }];
    _imageView3.image = [UIImage imageNamed:@"u=957005295,3708602591&fm=206&gp=0.jpg"];
    _imageView3.clipsToBounds = YES;
    _imageView3.contentMode = UIViewContentModeScaleAspectFill;
    
    
    UIImageView *line = [UIImageView new];
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_imageView1.mas_bottom).offset(28/3 * AUTO_HEIGHT);
        make.left.mas_equalTo(15 * AUTO_WIDTH);
        make.height.mas_equalTo(1.5 * AUTO_HEIGHT);
        make.right.mas_equalTo(- 15 * AUTO_WIDTH);
        
    }];
    line.image = [UIImage imageNamed:@"虚线"];
    
    
    _text1 = [UILabel new];
    _text1.backgroundColor = GH;
    _text1.text = @"纯设计";
    _text1.font = [UIFont fontWithName:TFont size:TEXTLABELFONT * AUTO_WIDTH];
    _text1.textColor = [UIColor whiteColor];
    _text1.textAlignment = NSTextAlignmentCenter;
    //裁掉边框
    _text1.layer.masksToBounds = YES;
    //设置半径
    _text1.layer.cornerRadius = 4 *AUTO_HEIGHT;
    [self.contentView addSubview:_text1];
    [_text1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(line.mas_bottom).offset(18/3 * AUTO_HEIGHT);
        make.width.mas_equalTo(70 * AUTO_WIDTH);
        make.height.mas_equalTo(20 * AUTO_HEIGHT);
        make.left.mas_equalTo(87/2 *AUTO_WIDTH);
        
    }];
    
    
    _text2 = [UILabel new];
    _text2.backgroundColor = GH;
    _text2.text = @"需要跟单";
    _text2.font = [UIFont fontWithName:TFont size:TEXTLABELFONT * AUTO_WIDTH];
    _text2.textColor = [UIColor whiteColor];
    _text2.textAlignment = NSTextAlignmentCenter;
    //裁掉边框
    _text2.layer.masksToBounds = YES;
    //设置半径
    _text2.layer.cornerRadius = 4 *AUTO_HEIGHT;
    [self.contentView addSubview:_text2];
    [_text2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(line.mas_bottom).offset(18/3 * AUTO_HEIGHT);
        make.left.equalTo(_text1.mas_right).offset(3 *AUTO_WIDTH);
        make.width.mas_equalTo(70 * AUTO_WIDTH);
        make.height.mas_equalTo(20 * AUTO_HEIGHT);
    }];
    
    
    _text3 = [UILabel new];
    _text3.backgroundColor = GH;
    _text3.text = @"需要预算";
    _text3.font = [UIFont fontWithName:TFont size:TEXTLABELFONT * AUTO_WIDTH];
    _text3.textColor = [UIColor whiteColor];
    _text3.textAlignment = NSTextAlignmentCenter;
    //裁掉边框
    _text3.layer.masksToBounds = YES;
    //设置半径
    _text3.layer.cornerRadius = 4 *AUTO_HEIGHT;
    [self.contentView addSubview:_text3];
    [_text3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(line.mas_bottom).offset(18/3 * AUTO_HEIGHT);
        make.left.equalTo(_text2.mas_right).offset(3 *AUTO_WIDTH);
        make.width.mas_equalTo(70 * AUTO_WIDTH);
        make.height.mas_equalTo(20 * AUTO_HEIGHT);
        
    }];
    
    _text4 = [UILabel new];
    _text4.backgroundColor = GH;
    _text4.text = @"需要施工";
    _text4.font = [UIFont fontWithName:TFont size:TEXTLABELFONT * AUTO_WIDTH];
    _text4.textColor = [UIColor whiteColor];
    _text4.textAlignment = NSTextAlignmentCenter;
    //裁掉边框
    _text4.layer.masksToBounds = YES;
    //设置半径
    _text4.layer.cornerRadius = 4 *AUTO_HEIGHT;
    [self.contentView addSubview:_text4];
    [_text4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(line.mas_bottom).offset(18/3 * AUTO_HEIGHT);
        make.right.mas_equalTo(-87/2 *AUTO_WIDTH);
        make.width.mas_equalTo(70 * AUTO_WIDTH);
        make.height.mas_equalTo(20 * AUTO_HEIGHT);
        
    }];
    
}

-(void)settingModel:(ResignModel *)model{
    [_myImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HTTPURL,model.headpic]] placeholderImage:[UIImage imageNamed:@"_myImageView"]];
    if ([model.sex isEqualToString:@"男"]) {
        _sexImageView.image = [UIImage imageNamed:@"xingbeinan"];
    }
    else if ([model.sex isEqualToString:@"女"]){
    
        _sexImageView.image = [UIImage imageNamed:@"xingbeinv"];

    }
    _nameL.text = model.name;
    _priceL.text = [NSString stringWithFormat:@"%@%@",model.money,@"元"];
    _addressL.text = [NSString stringWithFormat:@"%@%@",model.mianji,@"㎡"];
    _ageL.text = model.city;
    _styleL.text = model.sjyq;

    switch (model.simg.count) {
        case 0:
            
            break;
            case 1:
          
            [_imageView1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HTTPURL,[model.simg[0] objectForKey:@"simg"]]] placeholderImage:nil];
          
            break;
            case 2:
            [_imageView1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HTTPURL,[model.simg[0] objectForKey:@"simg"]]] placeholderImage:nil];
            [_imageView2 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HTTPURL,[model.simg[1] objectForKey:@"simg"]]] placeholderImage:nil];
            
            break;
            case 3:
            [_imageView1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HTTPURL,[model.simg[0] objectForKey:@"simg"]]] placeholderImage:nil];
            [_imageView2 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HTTPURL,[model.simg[1] objectForKey:@"simg"]]] placeholderImage:nil];
            [_imageView3 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HTTPURL,[model.simg[2] objectForKey:@"simg"]]] placeholderImage:nil];
        default:
            break;
    }

    

}


@end
